﻿namespace SourceCodeRepository.Model.ValidationRules.CodeSnippetRules
{
    using System;
    using Infra.Validation;

    /// <summary>
    /// Rule to validate the language field of the Code Snippet entity.
    /// </summary>
    public class LanguageInSnippetValidationRule : ValidationRuleFor<CodeSnippet>
    {
        /// <summary>
        /// Gets the rule number.
        /// </summary>
        /// <value>The rule number.</value>
        public override int RuleNumber
        {
            get { return 3; }
        }

        public override ValidationRuleFor<CodeSnippet> NextRule
        {
            get { return null; }
        }

        protected override void ValidateThisRule(CodeSnippet objectToValidate, ValidationResult validationResult)
        {
            if (Checkers.CheckIsNull(objectToValidate.Language))
            {
                validationResult.AddError("The Code Snippet must have a language.");
            }
        }
    }
}
